'''
Created on Jul 7, 2010

@author: riche
'''

from ft.framework import component, connector, fake_endp

class UncleanIO(Exception):
    pass

class IOComponent(component.Implementation):
    '''
    classdocs
    '''

    def __init__(self, name):
        '''
        Constructor
        '''
        component.Implementation.__init__(self, name)
        self.__input__ = component.Port('in', 'handle_input_stream')
        self.add_port(self.__input__)
        self.__output__ = component.Port('out', '__OUT__')
        self.add_port(self.__output__)

    def get_input_endpoint(self):
        return connector.Endpoint(self, self.__input__)
    
    def get_output_endpoint(self):
        return connector.Endpoint(self, self.__output__)
    
    def cleanup(self):
        raise UncleanIO()
    
    def get_dummy_conn(self):
        endp1 = fake_endp.generate_empty_endpoint()
        endp2 = self.get_input_endpoint()
        conn = connector.Connector(endp1, endp2)
        conn.put('ALLEZ')
        return conn

        
